/*
 *  naive.c
 *  StringSearch
 *
 *  Created by Mohammad H. Afrasiabi on 09-11-16.
 *  Copyright 2009 UBC. All rights reserved.
 *
 */

#include "naive.h"

char *	_pattern;
int		_patternSize;

int Naive_Init(char * pattern, int patternSize)
{
	_pattern		= pattern;
	_patternSize	= patternSize;
	
	return 0;
}

void Naive_Search(char * text, int textSize)
{
	short	found;
	int 	i, j;
	
	for (i = 0; i <= textSize - _patternSize; i++)
	{
		found = 1;
		for (j = 0; j < _patternSize; j++)
			if ( text[i+j] != _pattern[j])
				found = 0;
			else
				break;
		
		if (found)
			ADD_RESULT(i);
	}
}